//
//  BranchRequirementModel.m
//  ShangHaiHuDongApp
//
//  Created by apple on 17/8/10.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "BranchRequirementModel.h"

@implementation BranchRequirementModel
-(void)calculateTitleHeightAndCellHeightWithBeignY:(CGFloat)beginY itemTextHeight:(CGFloat)itemTextHeight{
    [super calculateTitleHeightAndCellHeightWithBeignY:beginY itemTextHeight:itemTextHeight];
    if (self.REQ_ADDRESS.length == 0) {
        self.addressHeight = ItemHeight * 39;
        NSString * addressString = @"需求位置：";
        self.addressAttributedString = [[NSMutableAttributedString alloc]initWithString:addressString];
        [self.addressAttributedString addAttribute:NSFontAttributeName value:LYPFONT(14) range:NSMakeRange(0, addressString.length)];
    }
    else{
        CGSize normalSize = [@"需求位置：" boundingRectWithSize:CGSizeMake(ItemWidth * 500, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : LYPFONT(14)} context:nil].size;
        CGFloat normalHeight = normalSize.height;
        NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc]init];
        [paragraphStyle setHeadIndent:normalSize.width];
        
        NSString * addressString = [NSString stringWithFormat:@"需求位置：%@" , self.REQ_ADDRESS];
        CGFloat textHeight = [addressString boundingRectWithSize:CGSizeMake(ItemWidth * 500, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : LYPFONT(14) , NSParagraphStyleAttributeName : paragraphStyle} context:nil].size.height;
        self.addressHeight = ItemHeight * 39 + textHeight - normalHeight;
        self.cellHeight = self.cellHeight + textHeight - normalHeight;
        self.addressAttributedString = [[NSMutableAttributedString alloc]initWithString:addressString];
        [self.addressAttributedString addAttribute:NSFontAttributeName value:LYPFONT(14) range:NSMakeRange(0, addressString.length)];
        [self.addressAttributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, addressString.length)];
    }
    
}
@end
